<template>
    <view >

        <view class="fullTelMask " :class="{'show':isShow}"></view>
        <view class="home-user" :class="{'show':isShow}">
            <view class='hold-img-box'>
                <view class="tit"><text>温馨提示</text></view>
                <view class="content">
                    {{ message || '您还未开通此业务'}}
                </view>
                <view class="btnBox">
                    <button class="openBtn" style="width:160px;height: 90rpx;line-height:90rpx;font-size: 30rpx; background-color: transparent; " @click="close">取消</button>
                    <button class="openBtn" style="width:160px;height: 90rpx;line-height:90rpx;font-size: 30rpx; background-color: transparent; color: #1587fa; " @click="goOpen"> {{ this.isUp ? '去升级' : '去开通'  }}</button>
                </view>
            </view>

        </view>

    </view>

</template>
<script>
const app = getApp();
export default {
    props: {
        productType:{
            type:String | Number
        },
        message:{
            type:String,
            default:'您还未开通此业务!!'
        },
        params:String
    } ,
    components: {},
    computed:{
        canUseProduct(){ return this.$store.getters.userInfo.canUseProduct},
        termOfValidityDate(){ return this.$store.getters.userInfo.termOfValidityDate},
        isShow( ){
           return !this.canUse
        }
    },
    data () {
        return {
            outTime:false, //是否过期
            remarkVal:'',
            //是否可以用此业务
            canUse:true, 
            isUp:false, // 是否升级会员
        }
    },
    watch:{
        canUseProduct(){
            this.outFunc()
        }
    },
    mounted(){

        // this.outFunc()

    },
    methods: {

        handleVailFunc(){

            this.outFunc()

            return this.canUse

        },

        outFunc(){


            // console.log('999999999999999999',this.canUseProduct,this.canUseProduct.includes( this.productType ))

            let now = new Date().getTime()
            let  termOfValidityDate = new Date(  this.termOfValidityDate ).getTime( )

            this.isUp = false

            if(now > termOfValidityDate){

                this.$emit('update:message', '会员已过期，请重新开通!!')

                this.outTime = true
                this.canUse = false

                this.$emit('initMember', this.canUse )

                return
            }
            
            //是否开通有会员业务
            if(!this.canUseProduct){

                this.$emit('update:message', '您还未开通此业务!!')

                this.canUse = false
            }
            //附带业务
            else if( this.productType == '*' ){

                this.canUse = true
            }
            //是否开通此业务
            else if( !this.canUseProduct.includes( this.productType )){

                this.isUp = true

                this.$emit('update:message', '您还未开通此业务,可升级会员开通!')

                this.canUse = false
            }
            else{
                this.canUse = true
            }

            this.$emit('initMember', this.canUse )
           
        },
        fininsh () {
  
            this.$emit('finish')

            this.close()

            // uni.navigateBack();
            

        },
        close () {
           
            this.canUse = true

            // uni.navigateBack();

            // this.$emit('update:isShow',false)

            //获取当前页面路径

            
        },
        goOpen(){

            var pages = getCurrentPages() // 获取栈实例

            let currentPage = pages[pages.length - 1]['$page']['fullPath']

            let cbUrl = this.params ? ( this.params + '&cb=' + currentPage) : ( '&?cb=' + currentPage)

            this.canUse = true

            if(this.isUp){
                this.isUp = false
                this.$goNext('/pages/member/upgrade'+ cbUrl )
            }
            else{
                this.$goNext('/pages/member/index'+ cbUrl )
            }

            
        }
    }
}
</script>

<style scoped lang="scss">
.fullTelMask {
    /* background:#ffffff; */
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    display: none;
}
.fullTelMask.show {
    display: block;
}
.home-user {
    position: fixed;
    /* height: 360rpx; */
    background-color: #fff;
    z-index: 52;
    top: 20%;
    left: 50%;
    transform: translate(-50%, 0%);
    border-radius: 14rpx;
    display: none;
}
.home-user.show {
    display: block;
}

.hold-img-box {
    width: 100%;
    position: relative;
    text-align: center;
    border-radius: 6px;
    overflow: hidden;
    margin: 30rpx 0 0rpx;
    box-sizing: border-box;
    padding: 0;
}

.hold-img-box .tit {
    color: #000;
    font-weight: bold;
    text-align: center;
    /* margin-top: 20rpx; */
    font-size: 32rpx;
    padding: 30rpx 50rpx;
}
.hold-img-box .content {
    padding: 10rpx 0 30rpx 0;
    text-align: center;
    textarea{
        margin: 0 30rpx;
        border: 1rpx solid #eaeaea;
        padding: 24rpx;
        border-radius: 6px;
        font-size: 26rpx;
        height: 80px;
    }
}

.hold-img-box .h1 {
    color: #777777;
    text-align: center;
    font-size: 28rpx;
}
.btnBox {
    position: relative;
    margin-top: 20px;
    display: flex;
    border-top: 1rpx solid #eaeaea;
    /* background-color: #f1f1f1; */
}
.btnBox::after {
    position: absolute;
    left: 50%;
    content: " ";
    width: 1px;
    height: 100%;
    background-color: #eaeaea;
}
.btnBox .openBtn {
    flex: 1;
}
.openBtn {
    padding: 0;
    height: 60rpx;
    line-height: 60rpx;
    text-align: center;
    font-size: 26rpx;
    background-color: #1587fa;
    margin: 0;
    color: #000;
}

.niIpt {
    /* width: 100%; */
    display: flex;
    margin-top: 30rpx;
    align-items: center;
    padding: 0 40rpx;
    box-sizing: border-box;
    background-color: #f1f1f1;
    height: 70rpx;
    border-radius: 70rpx;
    margin: 30rpx 110rpx 0;
}
.niIpt input {
    flex: 1;
    text-align: center;
    padding: 0 30rpx;
    box-sizing: border-box;
    font-size: 32rpx;

    /* border-bottom: 1px solid; */
}
</style>
